﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VotesResults.Daos;
using VotesResults.Daos.EntityFramework;
using VotesResults.Models;

namespace VotesResults.Controllers
{
    public class StatisticsController : Controller
    {
        private readonly IQuestionDao _questionDao = new QuestionDao();
        private readonly IVoteDao _voteDao = new VoteDao();
        private readonly IGroupDao _groupDao = new GroupDao();

        //
        // GET: /Statistics/

        public ActionResult Index()
        {
            return View(_voteDao.Load());
        }

        public ActionResult Show(int voteId)
        {
            List<QuestionModel> questionModels = _questionDao.LoadAvgMarks(voteId);

            return View(
                new ResultModel
                {
                    VoteName = _voteDao.Get(voteId).Name, 
                    QuestionModels = _questionDao.LoadAvgMarks(voteId), 
                    ActualQuestions = _questionDao.LoadActualQuestions(voteId), 
                    GroupModels = _groupDao.LoadVoted(voteId)
                });
        }
    }
}
